﻿/*
 
Celerity: Sensory Overload
Copright 2012 by Adam Hill, David Gannon, Thomas Tamblyn & Patrick Ytting
Contact: adam.hill@outlook.com
Website: adamhill.org
Licence: MS-Pl Licence
  
 */

using Microsoft.Xna.Framework;
using System.Collections.Generic;

namespace Celerity.UI.Definition
{
    public class UIGeometry
    {
        // Sizes
        Vector2 uis = new Vector2(1000, 600); // Main container width/height
        Vector2 ts = new Vector2(500, 125); // Top left/right container width/height
        Vector2 iconSize = new Vector2(95, 115);
        Vector2 panelSize = new Vector2(200, 150);
        Vector2 popupSize = new Vector2(450, 350);
        Vector2 messageSize = new Vector2(950, 100);
        Vector2 titleSize = new Vector2(300, 75);
        Vector2 logoSize = new Vector2(500, 125);
        Vector2 popupCalibratorSize = new Vector2(450, 350);
        Vector2 newTallPanelSize = new Vector2(200, 350);
        Vector2 playBarSize = new Vector2(450, 75);
        Vector2 cameraFpsButtonSize = new Vector2(110, 75);
        Vector2 iconBombCounterPanelSize = new Vector2(350, 125);
        Vector2 inGameScoreSize = new Vector2(180, 75);

        // Offsets
        Vector2 uio = Vector2.Zero; //"UI Origin" - Main container panel, centred on screen, 1000x500px
        Vector2 tlo = Vector2.Zero; // "Top Left Origin" - Top left container panel, Back button, logo & titles, 450x75px
        Vector2 tro = Vector2.Zero; // "Top Right Origin" - Top right container panel, Icon buttons, 450x75px
        Vector2 iconBackOffset = Vector2.Zero;
        Vector2 iconPauseOffset = Vector2.Zero;
        Vector2 iconMuteOffset = Vector2.Zero;
        Vector2 iconMinimizeOffset = Vector2.Zero;
        Vector2 iconCloseOffset = Vector2.Zero;
        Vector2 panelStartOffset = Vector2.Zero;
        Vector2 panelControlOffset = Vector2.Zero;
        Vector2 panelModeOffset = Vector2.Zero;
        Vector2 panelAboutOffset = Vector2.Zero;
        Vector2 messageAlignInstructionsDoNotCrashOffset = Vector2.Zero;
        Vector2 popupNoWebcamOffset = Vector2.Zero;
        Vector2 popupGameOverOffset = Vector2.Zero;
        Vector2 popupInstructionsOffset = Vector2.Zero;
        Vector2 popupAboutDevsOffset = Vector2.Zero;
        Vector2 aboutPageTitleOffset = Vector2.Zero;
        Vector2 logoOffset = Vector2.Zero;
        Vector2 popupCalibratorOffset = Vector2.Zero;
        Vector2 panelAboutDevsOffset = Vector2.Zero;
        Vector2 controlStatusesControlOffset = Vector2.Zero;
        Vector2 cameraFpsButtonFastOffset = Vector2.Zero;
        Vector2 cameraFpsButtonSlowOffset = Vector2.Zero;
        Vector2 cameraFpsButtonOverrideOffset = Vector2.Zero;
        Vector2 iconBombOffset = Vector2.Zero;
        Vector2 iconHeartOffset = Vector2.Zero;
        Vector2 blo = Vector2.Zero; // "Bottom Left Origin" - Bottom left container panel, Icon buttons
        Vector2 bro = Vector2.Zero; // "Bottom Right Origin" - Bottom right container panel, Icon buttons
        Vector2 inGameScoreOffset = Vector2.Zero;

        // Externally referenced
        public static Vector2 IconTextOffset = new Vector2(0, 75);
        public static Vector2 PanelTextOffset = new Vector2(10, 112);
        public static Vector2 PopupTextOffset = new Vector2(0, 260);
        public static Vector2 TitleOffset = new Vector2(40, -15);
        public static Vector2 InstructionsTitleOffset = new Vector2(10, 5);
        public static Vector2 AboutDevsTitleOffset = new Vector2(10, 5);

        // Properties
        public List<Vector2> Sizes { get; set; }
        public List<Vector2> Offsets { get; set; }

        // Constructor
        public UIGeometry()
        {
            Sizes = new List<Vector2>
            {
                uis, // UI = 0,
                ts, // TL = 1,
                ts, // TR = 2,
                iconSize, // IconBack = 3,
                iconSize, // IconPause = 4,
                iconSize, // IconMute = 5,
                newTallPanelSize, // AboutDevs = 6, // IconMinimize = 6,
                iconSize, // IconClose = 7,
                playBarSize,//panelSize,  // PanelStart = 8,
                panelSize, // PanelControl = 9,
                newTallPanelSize, // PanelMode = 10,
                panelSize, // PanelAbout = 11,        
                messageSize, // MessageAlign = 12,
                popupSize, // PopupNoWebcam = 13,
                popupSize, // PopupGameOver = 14,
                popupSize, // PopupInstructions = 15,
                popupSize, // PopupAboutDevs = 16
                titleSize, // Title = 17
                logoSize, // Logo = 18,
                popupCalibratorSize, // PopupCalibrator = 19,
                popupCalibratorSize, // PopupCameraFps = 20,
                cameraFpsButtonSize, // PopupCameraFpsFast = 21,
                cameraFpsButtonSize, // PopupCameraFpsSlow = 22,
                cameraFpsButtonSize, // PopupCameraFpsOverride = 23,
                iconBombCounterPanelSize, // IconBomb = 24,
                iconBombCounterPanelSize, //IconHeart = 25,
                inGameScoreSize, // InGameScore = 26,
            };

            CalculateOffsets();

            Offsets = new List<Vector2>
            {
                uio, // UI = 0,
                tlo, // TL = 1,
                tro, // TR = 2,
                iconBackOffset, // IconBack = 3,
                iconPauseOffset, // IconPause = 4,
                iconMuteOffset, // IconMute = 5,
                panelAboutDevsOffset, //iconMinimizeOffset, // IconMinimize = 6,
                iconCloseOffset, // IconClose = 7,
                panelStartOffset,  // PanelStart = 8,
                panelControlOffset, // PanelControl = 9,
                controlStatusesControlOffset, //panelModeOffset, // PanelMode = 10,
                panelAboutOffset, // PanelAbout = 11,        
                messageAlignInstructionsDoNotCrashOffset, // MessageAlign = 12,
                popupNoWebcamOffset, // PopupNoWebcam = 13,
                popupGameOverOffset, // PopupGameOver = 14,
                popupInstructionsOffset, // PopupInstructions = 15,
                popupAboutDevsOffset, // PopupAboutDevs = 16
                aboutPageTitleOffset, // Title = 17,
                logoOffset, // Logo = 18,
                popupCalibratorOffset, // PopupCalibrator = 19,
                popupCalibratorOffset, // PopupCameraFps = 20,
                cameraFpsButtonFastOffset, // PopupCameraFpsFast = 21,
                cameraFpsButtonSlowOffset, // PopupCameraFpsSlow = 22,
                cameraFpsButtonOverrideOffset, //PopupCameraFpsOverride = 23
                iconBombOffset, // IconBomb = 24,
                iconHeartOffset, // IconHeart = 25,
                inGameScoreOffset, // InGameScore = 26,
            };
        }

        void CalculateOffsets()
        {
            // Make these panels either:
            // Align to outside edge if hi res
            // Or stay within safe zone & aligned if lo res
            bool isHiRes = CeleritySettings.WindowWidth > 1024;
            float x = CeleritySettings.WindowWidth / 2f - (uis.X / 2f);
            float y = CeleritySettings.WindowHeight / 2f - (uis.Y / 2f);
            uio = new Vector2 { X = x, Y = y };
            tlo = new Vector2 { X = isHiRes ? 0 : uio.X, Y = 0 };
            tro = new Vector2 { X = isHiRes ? CeleritySettings.WindowWidth - ts.X : uio.X + ts.X, Y = 0 };
            bro = new Vector2 { X = CeleritySettings.WindowWidth - 350, Y = CeleritySettings.WindowHeight - 150 };
            blo = new Vector2 { X = 25, Y = CeleritySettings.WindowHeight - 150 };

            // Main elements
            iconBackOffset = tlo + new Vector2(25, 25);
            iconPauseOffset = tro + new Vector2(150, 25) + new Vector2(-20, 0);
            iconMuteOffset = tro + new Vector2(275, 25) + new Vector2(-20, 0);
            iconMinimizeOffset = tro + new Vector2(275, 25) + new Vector2(-20, 0);
            iconCloseOffset = tro + new Vector2(400, 25) + new Vector2(-20, 0);
            panelStartOffset = uio + new Vector2(275, 500);
            panelControlOffset = uio + new Vector2(775, 125);
            panelModeOffset = uio + new Vector2(25, 325);
            panelAboutOffset = uio + new Vector2(775, 325);
            messageAlignInstructionsDoNotCrashOffset = uio + new Vector2(25, 00);
            popupNoWebcamOffset = uio + new Vector2(275, 125);
            popupGameOverOffset = uio + new Vector2(275, 125);
            popupInstructionsOffset = uio + new Vector2(25, 125);
            popupAboutDevsOffset = uio + new Vector2(525, 125);
            aboutPageTitleOffset = tlo + new Vector2(100, 25);
            logoOffset = tlo + Vector2.Zero;
            popupCalibratorOffset = uio + new Vector2(275, 125);
            panelAboutDevsOffset = uio + new Vector2(775, 125);
            controlStatusesControlOffset = uio + new Vector2(25, 125);
            cameraFpsButtonFastOffset = uio + new Vector2(585, 170);
            cameraFpsButtonSlowOffset = uio + new Vector2(445, 170);
            cameraFpsButtonOverrideOffset = uio + new Vector2(305, 170);
            iconBombOffset = blo;
            iconHeartOffset = bro;
            inGameScoreOffset = iconBackOffset + new Vector2(iconSize.X + 25, 0);
        }
    }
}
